#ifndef USRAI_H
#define USRAI_H

#include "AI.h"

extern tagGame tagUsrGame;
extern ins UsrIns;
/*##########DO NOT MODIFY THE CODE ABOVE##########*/

class UsrAI:public AI
{
public:
    UsrAI(){this->id=0;}
    ~UsrAI(){}
    void farmerAction();
    void huttingGazelle();
    void fishingFish();
    void createFarmer();
    void createSailing();
    void createBoat();
    void createShip();
    void destroyFish();
    void destroyShip();
    void updateScience();
    void assignBoardTask(vector<tagFarmer> &landFarmer,vector<tagFarmer> &boardFarmer);
    void exploreOcean(tagHuman & human);
    void assignOceanTask();
    void assginTransportTask();
    void assignBuildTask(int BUILDING_TYPE,vector<tagFarmer>& idleFarmer,vector<tagFarmer>& workingFarmer,int workingNum,pair<int,int> goal,int BUILDING_RESOURCE,int buildingNum=1);
    void assignResourceTask(int RESOURCE_TYPE,vector<tagFarmer>& idleFarmer,vector<tagFarmer>& workingFarmer,int workingNum);
private:
    void processData() override;
    tagInfo getInfo(){return tagUsrGame.getInfo();}
    int AddToIns(instruction ins) override
    {
        UsrIns.lock.lock();
        ins.id=UsrIns.g_id;
        UsrIns.g_id++;
        UsrIns.instructions.push(ins);
        UsrIns.lock.unlock();
        return ins.id;
    }
    void clearInsRet() override
    {
        tagUsrGame.clearInsRet();
    }
    /*##########DO NOT MODIFY THE CODE IN THE CLASS##########*/
    bool tryBuildBuilding(int buildingType, int requiredWood, int maxCount, int reqiredBuilding,int is_settler=0);
    //
};

/*##########YOUR CODE BEGINS HERE##########*/
void initMap();
void initFarmer();
void initArmy();
void init();
void findNearestResource();
bool isEnermyLand(int DR, int UR);
bool isPreBuild(int);
bool isNearCenter(int,int);
pair<int,int> findBeginPos();
/*##########YOUR CODE ENDS HERE##########*/
#endif // USRAI_H
